{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "efb02112",
   "metadata": {},
   "source": [
    "## 哈希表\n",
    "定义：\n",
    "类型：\n",
    "哈希碰撞\n",
    "为什么哈希表的复杂度为O(1)?\n",
    "字母异位词是通过重新排列不同单词或短语的字母而形成的单词或短语，并使用所有原字母一次"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4a3125cc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "## 字母异位词\n",
    "class Solution:\n",
    "    def isAnagram(self,s:str,t:str) -> bool:\n",
    "        record = [0]*26\n",
    "        for i in s:\n",
    "            record[ord(i) - ord('a')] += 1\n",
    "\n",
    "        for j in t:\n",
    "            record[ord(j) - ord('a')] -= 1\n",
    "\n",
    "        for k in range(26):\n",
    "            if record[k] != 0:\n",
    "                return False\n",
    "\n",
    "        return True\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    sr = 'abddfcz'\n",
    "    tr = 'abdfczd'\n",
    "\n",
    "    sol = Solution().isAnagram(sr,tr)\n",
    "    print(sol)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "env_py38",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
